function sim = sim_data_function(param,fp)
  
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%;
%Solving the model (Baseline or Counterfactual);
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%;

if fp.do_counter==0
        
    sim_data         = cell(4,1);
    sim_data_network = cell(4,1);

    Value0 = cell(4,1);
    Value1 = cell(4,1);
    
for j = 1:4
    
    s = solve(j,fp,param);

    sim_data{j} = s.sim_data ; 
    sim_data_network{j} = s.sim_data_network;
        
    Value0{j} = s.Value0;
    Value1{j} = s.Value1;

    
end

    sim.sim_data          = sim_data;
    sim.sim_data_network  = sim_data_network;   
    
    sim.Value0            = Value0;
    sim.Value1            = Value1;    
   
    
    
else %counterfactual=1

    
    if fp.do_counter_type < 4
    
    s_c = solve_counter(fp,param);
    sim_data_counter = s_c.sim_data;
    sim_data_network_counter = s_c.sim_data_network;
    id_moved_children        = s_c.id_moved_children;        
    
    sim.sim_data          = sim_data_counter;
    sim.sim_data_network  = sim_data_network_counter;    
    sim.id_moved_children = id_moved_children;
    
    
    else % fp.do_counter_type>=4 for the rest of the policy analysis
        
        
    sim_data         = cell(4,1);
    sim_data_network = cell(4,1);

    
    for j = 1:4
    
        s = solve(j,fp,param);

        sim_data{j} = s.sim_data ; 
        sim_data_network{j} = s.sim_data_network;

    
    end

    sim.sim_data          = sim_data;        
    sim.sim_data_network  = sim_data_network;          
        
    end
    
    
end

